import * as Api from 'src/api/net';
import router from 'src/router';
const MOCK_HOST = "http://localhost:3000";


const URL_Check_Login: URL_MOCK = {
    url: '/xin_check_login.do',
    mock: false,
    mockHost: MOCK_HOST //统一模块配置, 或者单独配置
}

const URL_Login: URL_MOCK = {
    url: '/xin_login.do',
    mock: false,
    mockHost: MOCK_HOST //统一模块配置, 或者单独配置
}

const URL_AuthCode: URL_MOCK = {
    url: 'test/authCode.do?' + Math.random(),
    mock: false,
    mockHost: MOCK_HOST
}

const URL_Logout: URL_MOCK = {
    url: '/xin_logout.do',//注销
    mock: false,
    mockHost: MOCK_HOST //统一模块配置, 或者单独配置
}

/** 验证是否登录 在刷新页面时验证*/
export const ajaxCheckLogin = (func: any) => {
    Api.AjaxPost(Api.urlHandler(URL_Check_Login), {}, func);
}

/** 登录 */
export const ajaxLogin = (data: LoginReq, func: any) => {
    Api.AjaxPost_Login(Api.urlHandler(URL_Login), data, func);
}

/** 注销 */
export const ajaxLogout = (func: any) => {
    Api.AjaxPost(Api.urlHandler(URL_Logout), {}, func);
}

/* 跳转到登录页面 */
export const skipLogin = () => {
    router.push({ path: '/loign' })
}

/* 测试其他请求 */
const URL_TESTREQ: URL_MOCK = {
    url: '/company/list.do?',
    mock: false,
    mockHost: MOCK_HOST
}

/** 请求数据（公司） */
export const ajaxGetCompanyData = (data: LoginReq, func: any) => {
    Api.AjaxPost(Api.urlHandler(URL_TESTREQ), data, func);
}